package it.sda.sviluppi.common;

import java.util.Date;

import javax.servlet.jsp.PageContext;

import org.displaytag.decorator.DisplaytagColumnDecorator;
import org.displaytag.exception.DecoratorException;
import org.displaytag.properties.MediaTypeEnum;

public class StandardFieldColumnDecorator implements DisplaytagColumnDecorator {
	public Object decorate(Object columnValue, PageContext pageContext, MediaTypeEnum media) throws DecoratorException {
		String returnValue=" ";
		if (columnValue!=null) {
			if (columnValue instanceof Date) {
				returnValue = UtilityDate.getDateIt((Date)columnValue);
			}
			else if (columnValue instanceof Boolean) {
				returnValue = ((Boolean)columnValue).booleanValue()?"SI":"NO";
			}
			else if (columnValue instanceof String) {
				returnValue = ((String)columnValue).trim().length()==0?" ":((String)columnValue);
			}
			else returnValue = columnValue.toString();
		}
		return returnValue;
	}
}